/**
 * 字典表单配置
 * @typedef {Object} FormConfig
 */
export const formConfig = [
  {
    field: 'name',
    label: '字典名称',
    component: 'Input',
    placeholder: '请输入字典名称',
    rules: [
      { required: true, message: '请输入字典名称', trigger: 'blur' },
      { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
    ]
  },
  {
    field: 'code',
    label: '字典编码',
    component: 'Input',
    placeholder: '请输入字典编码',
    editDisabled: true,
    rules: [
      { required: true, message: '请输入字典编码', trigger: 'blur' },
      { pattern: /^[a-z][a-z0-9_]*$/, message: '以小写字母开头，只能包含小写字母、数字和下划线', trigger: 'blur' }
    ]
  },
  {
    field: 'description',
    label: '字典描述',
    component: 'Input',
    placeholder: '请输入字典描述',
    props: {
      type: 'textarea',
      rows: 3
    }
  },
  {
    field: 'sort',
    label: '排序',
    component: 'Input',
    placeholder: '请输入排序号',
    props: {
      type: 'number',
      min: 0
    },
    rules: [
      { required: true, message: '请输入排序号', trigger: 'blur' }
    ]
  },
  {
    field: 'status',
    label: '状态',
    component: 'Radio',
    options: [
      { label: '启用', value: '1' },
      { label: '禁用', value: '0' }
    ],
    rules: [
      { required: true, message: '请选择状态', trigger: 'change' }
    ]
  }
]

/**
 * 获取表单默认值
 */
export const getDefaultFormData = () => {
  return {
    id: '',
    name: '',
    code: '',
    description: '',
    sort: 0,
    status: '1'
  }
} 